﻿using D.Medicalcare.Domain.Entities;
using D.Medicalcare.ErrorCode;
using D.Medicalcare.Infrastructure.Implement;
using D.Medicalcare.Infrastructure.Interfaces;
using D.Medicalcare.Read.API.Application.Command.PhysicalExaminationInstructionsCommand;
using MediatR;

namespace D.Medicalcare.Read.API.Application.Handler.PhysicalExaminationInstructionsHarder
{
    public class GetPhysicalExaminationInstructionsHarder : IRequestHandler<GetPhysicalExaminationInstructionsCommand, APIResult<List<PhysicalExaminationInstructions>>>
    {

        private readonly IBaseRepository<PhysicalExaminationInstructions> repository;

        public GetPhysicalExaminationInstructionsHarder(IBaseRepository<PhysicalExaminationInstructions> repository)
        {
            this.repository = repository;
        }

        public Task<APIResult<List<PhysicalExaminationInstructions>>> Handle(GetPhysicalExaminationInstructionsCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<PhysicalExaminationInstructions>> result = new APIResult<List<PhysicalExaminationInstructions>>();
            result.Code = APIEnum.Mvc;
            result.Msg = "查询成功";
            var list = repository.GetAll().ToList();
            result.Data= list;

            return Task.FromResult(result);

        }
    }
}
